<template>
  <!-- swiper首页轮播图 -->
  <swiper class="banner" :indicator-dots="true" indicator-color="#fff" indicator-active-color="#f00">
    <swiper-item v-for="item in bannerList" :key="item.goods_id">
      <image :src="item.image_src" mode="" />
    </swiper-item>
  </swiper>

  <view class="main">
    <Dialog :title="title"></Dialog>
    <!-- <navigator v-for="" :url="item.url" open-type="navigate" hover-class="className">去列表页</navigator> -->
    <!-- <button @click="goUrl">跳转</button> -->
  </view>
</template>

<script setup lang="ts">
//import { onReady, onShow } from "@dcloudio/uni-app";
import { onMounted, ref } from "vue";
import * as API from '../../http/api'
import type { IbannerItem } from '@/dataType/index'
import Dialog from '@/components/Dialog/index.vue'

const title = ref('我是index数据')
const url = ref('/pages/list/index?id=666&name=liming')

onMounted(() => {
  console.log('onMounted')
  getBanner()
})


const goUrl = () => {
  uni.navigateTo({
    url: '/pages/list/index?id=666&name=liming'
  })
  // uni.switchTab({
  //   url: '/pages/shop/shop'
  // })
}


const bannerList = ref<IbannerItem[]>([])
const getBanner = async () => {
  const res = await API.getBannerListApi()
  console.log('轮播图：', res)
  bannerList.value = res.message
}

</script>

<style>
.banner image {
  width: 100%;
  height: 100%;
}
</style>
